package cn.tedu.review;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;

public class TestFile {
    public static void main(String[] args) throws IOException {
        File file=new File("D:\\ready\\1.txt");

        System.out.println(file.length());//9
        System.out.println(file.exists());//t
        System.out.println(file.isFile());//t
        System.out.println(file.isDirectory());//f

        System.out.println(file.getName());//1.txt
        System.out.println(file.getParent());//D:\ready
        System.out.println(file.getAbsoluteFile());//D:\ready\1.txt

        File file2=new File("D:\\ready\\2,txt");
        file2.createNewFile();
        File file3=new File("D:\\ready\\bbb");
        System.out.println(file3.mkdir());
        File file4=new File("D:\\ready\\x\\y\\z");
        System.out.println(file4.mkdirs());

        file4.delete();
        file3.delete();
        file2.delete();

        File file5=new File("D:\\ready");
        String[] list=file5.list();
        System.out.println(Arrays.toString(list));//[1.txt, a, x]

        File[] fs=file5.listFiles();
        System.out.println(fs[1].isDirectory());//true
    }
}
